import { _decorator, Component, Label, Node, Size, Sprite, UITransform } from 'cc';
import { DailyTurntable } from './DailyTurntable';
import { turntable_config } from '../manager/AppControll';
import { DataHelper } from '../system/DataHelper';
import { Loader } from '../tools/LoadManger';
import { Tools } from '../tools/Tools';
const { ccclass, property } = _decorator;

@ccclass('TurnTableItem')
export class TurnTableItem extends Component {
    private mNdIcon: Node = null;
    private mNdNumber: Node = null;
    protected onLoad(): void {

    }

    start() {

    }

    update(deltaTime: number) {

    }

    InitItem(config: turntable_config) {
        this.mNdIcon = this.node.getChildByName("icon");
        this.mNdNumber = this.node.getChildByName("num");
        let propConfig = DataHelper.GetPropConfigById(config.rewardProp);
        let size = new Size(propConfig.IconSize[0], propConfig.IconSize[1]);
        this.mNdIcon.getComponent(UITransform).setContentSize(size);
        if (propConfig.propType != 1) {
            this.mNdNumber.getComponent(Label).string = propConfig.propNum + "";
        } else {
            this.mNdNumber.getComponent(Label).string = Tools.FormatNumber(propConfig.propNum * DataHelper.GetMonsterRefreshByAuto().LimitedTimeAwardGold);
        }

        Loader.GetTurnTableRewardImage("rewardIcon/" + propConfig.propIcon, (spf) => {
            this.mNdIcon.getComponent(Sprite).spriteFrame = spf;
        })
    }
}


